package com.guigu.tms.oms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guigu.tms.commons.order.entity.TaskPickupDispatch;
import com.guigu.tms.oms.mapper.TaskPickupDispatchMapper;
import com.guigu.tms.oms.service.IAuthUserService;
import com.guigu.tms.oms.service.ICoreOrgService;
import com.guigu.tms.oms.service.ITaskPickupDispatchService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 取件、派件任务信息表 服务实现类
 * </p>
 *
 * @author zwj
 * @since 2022-10-04
 */
@Service
//@DS("work")
public class TaskPickupDispatchServiceImpl extends ServiceImpl<TaskPickupDispatchMapper, TaskPickupDispatch> implements ITaskPickupDispatchService {

    @Autowired
    private TaskPickupDispatchMapper taskPickupDispatchMapper;

    @Autowired
    private ICoreOrgService orgService;
    @Autowired
    private IAuthUserService authUserService;
    @Override
    public TaskPickupDispatch getTaskPickupDispatchByOrderId(String orderId, Integer taskType) {
        QueryWrapper<TaskPickupDispatch> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("order_id",orderId);
        queryWrapper.eq("task_type",taskType);
        TaskPickupDispatch pickupDispatch = taskPickupDispatchMapper.selectOne(queryWrapper);
        //获取任务所属网点
        pickupDispatch.setAgency(orgService.getCoreOrgById(pickupDispatch.getAgencyId()));
        //获取快递员
        pickupDispatch.setCourier(authUserService.getById(pickupDispatch.getCourierId()));
        return pickupDispatch;
    }
}
